<template>
  <el-drawer title="列显隐" :visible.sync="drawer" direction="rtl" size="40%" :before-close="handleClose">
    <div class="drawer_content">
      <el-table :data="tableData" border style="width: 100%" height="500">
        <el-table-column prop="label" label="列名" align="center"></el-table-column>
        <el-table-column prop="hide" label="隐藏" align="center">
          <template slot-scope="scope">
            <el-checkbox v-model="scope.row.hide"></el-checkbox>
          </template>
        </el-table-column>
        <el-table-column prop="fixed" label="冻结" align="center">
          <template slot-scope="scope">
            <el-checkbox v-model="scope.row.fixed"></el-checkbox>
          </template>
        </el-table-column>
        <!-- <el-my-table-column prop="sortable" label="排序" align="center">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.sortable"></el-checkbox>
            </template>
          </el-my-table-column> -->
      </el-table>
    </div>
  </el-drawer>
</template>

<script>
export default {
  data() {
    return {
      drawer: false,
      tableData: [],
    }
  },
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    list: {
      type: Array,
      default: () => [],
    },
  },
  watch: {
    show(val) {
      this.drawer = val;
    },
  },
  mounted() {
    this.drawer = this.show;
    this.$nextTick(() => {
      this.tableData = this.list;
    })
  },
  methods: {
    handleClose(done) {
      this.$emit('update:show', false);
      done();
    }
  }
}
</script>

<style lang="scss" scoped>
.drawer_content {
  padding: 20px 20px;
  border-top: 1px #ccc solid;
}
</style>
